package leetcode.solution203;

public class _Solution {
    public static ListNode removeElements(ListNode head, int val) {
        ListNode dummyHead = new ListNode(-1);
        dummyHead.next = head;
        ListNode cur = dummyHead;
        while (cur.next != null){
            if(cur.next.val == val){
                ListNode delNode = cur.next;
                cur.next = delNode.next;
                delNode = null;

            }else {
                cur = cur.next;
            }
        }
        return dummyHead.next;
    }

    public static void main(String[] args) {
        int nums[] = {1};
        ListNode listNode = new ListNode(nums);
        System.out.println(listNode);
        System.out.println("++++++++++++++++");
        ListNode listNode1 = removeElements(listNode, 1);
        System.out.println(listNode1);
    }


}
